package com.bwie.home.backstage.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.home.common.utils.PageUtils;
import com.bwie.home.common.utils.Query;

import com.bwie.home.backstage.dao.CommunityDao;
import com.bwie.home.backstage.entity.CommunityEntity;
import com.bwie.home.backstage.service.CommunityService;


@Service("communityService")
public class CommunityServiceImpl extends ServiceImpl<CommunityDao, CommunityEntity> implements CommunityService {

    @Override
    public PageUtils queryPage(Map<String, Object> params, CommunityEntity community) {
        QueryWrapper<CommunityEntity> wrapper = new QueryWrapper<>();
        if (community.getName()!=null&&!"".equals(community.getName())){//判断是否有小区名称
            //有小区名称
            wrapper.like("name",community.getName());
        }
        if (community.getProvince()!=null&&!"".equals(community.getProvince())){//判断是否有省
            //有省
            wrapper.eq("province",community.getProvince());
        }
        if (community.getCity()!=null&&!"".equals(community.getCity())){//判断是否有市
            //有市
            wrapper.eq("city",community.getCity());
        }
        if (community.getCounty()!=null&&!"".equals(community.getCounty())){//判断是否有县
            //有县
            wrapper.eq("county",community.getCounty());
        }
        if(community.getStatus()!=null&&community.getStatus()!=0){//判断是否有状态
            //有状态
            wrapper.eq("status",community.getStatus());
        }
        IPage<CommunityEntity> page = this.page(
                new Query<CommunityEntity>().getPage(params), wrapper);
        return new PageUtils(page);
    }

}